package org.bookshare.document.reader;

import java.io.File;
import java.io.IOException;

import org.benetech.event.EventListener;
import org.bookshare.document.beans.DocumentSet;
import org.bookshare.document.beans.DocumentType;

/**
 * A module that can create a DocumentSet from a file (typically either a file or a zip). The implementation must define
 * an empty constructor.
 * @author Reuben Firmin
 * @param <T> the type of documents this reader can handle.
 */
public interface Reader<T extends DocumentType> {

    /**
     * Read the file, and transform it into a DocumentSet.
     * @param file The file to read, either a zip or a directory.
     * @param eventListener User feedback utility
     * @return Null if nothing can be read
     * @throws IOException if there is a file access problem.
     */
    DocumentSet<T> read(File file, EventListener eventListener)
    	throws IOException;

    /**
     * Set the tmp dir.
     * @param tmpDir The location of the temporary directory to use.
     * @throws IOException if the dir is a file, or if it can't be created.
     */
    void setTmpDir(final String tmpDir)
    	throws IOException;

    /**
     * Get the type of documents that this reader can read.
     * @return Never null
     */
    T getDocumentType();
}
